package com.hrhr74.penguinstream.utils;

import com.hrhr74.penguinstream.constant.UserConstant;
import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import java.time.Duration;

@Component
@RequiredArgsConstructor
public class WriteTokenToRedis {
    private final JwtTool jwtTool;
    public void writeTokenToRedis(String key, Long userId, StringRedisTemplate stringRedisTemplate){
        String token = jwtTool.createToken(userId, Duration.ofMinutes(UserConstant.TTL));
        stringRedisTemplate.opsForValue().set(key, token);
    }
}
